package com.atguigu.tingshu.common.util;

import com.atguigu.tingshu.common.execption.GuiguException;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class AssertUtil {


    public static void resultAssert(Result result , ResultCodeEnum codeEnum){
       /* if (result == null
                || !result.getCode().equals(ResultCodeEnum.SUCCESS.getCode())
                || result.getData() == null) {
            log.error("远程调用失败");
            throw new GuiguException(codeEnum);
        }*/
        if (result == null) {
            log.error("调用失败，返回结果为空" );
            throw new GuiguException(codeEnum);
        }

        if (!result.getCode().equals(ResultCodeEnum.SUCCESS.getCode()) ){
            log.error("调用失败，返回码不正确!=>" +result.getData());
            throw new GuiguException(codeEnum);
        }

        if (result.getData() == null) {
            log.error("数据为空");
            throw new GuiguException(codeEnum);
        }

        log.info("调用成功，访问数据：=>" + result.getData());
    }


}
